import * as TYPES from "../action-types";
import api from "../../api";
const userActions = {
  setToken(token) {
    return {
      type: TYPES.SET_TOKEN,
      payload: token,
    };
  },
  async getUserInfo() {
    let info = null;
    try {
      const { code, data } = await api.queryUserInfo();
      if (code === 0) {
        info = data;
      }
    } catch (error) {}
    return {
      type: TYPES.USER_INFO,
      info,
    };
  },
  clearUserInfo() {
    return {
      type: TYPES.USER_INFO,
      info: null,
    };
  },
};
export default userActions;
